home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / usr_-_Usr_Files / INCLUDE / LIBIO.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  9KB  |  291 lines

  1. /* 
  2. Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation
  3.  
  4. This file is part of the GNU IO Library.  This library is free
  5. software; you can redistribute it and/or modify it under the
  6. terms of the GNU General Public License as published by the
  7. Free Software Foundation; either version 2, or (at your option)
  8. any later version.
  9.  
  10. This library is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. GNU General Public License for more details.
  14.  
  15. You should have received a copy of the GNU General Public License
  16. along with GNU CC; see the file COPYING.  If not, write to
  17. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19. As a special exception, if you link this library with files
  20. compiled with a GNU compiler to produce an executable, this does not cause
  21. the resulting executable to be covered by the GNU General Public License.
  22. This exception does not however invalidate any other reasons why
  23. the executable file might be covered by the GNU General Public License. */
  24.  
  25. /* This is part of the iostream library.  Written by Per Bothner. */
  26.  
  27. #ifndef _LIBIO_H
  28. #define _LIBIO_H
  29.  
  30. #include <_G_config.h>
  31. #define _IO_pos_t _G_fpos_t /* obsolete */
  32. #define _IO_fpos_t _G_fpos_t
  33. #define _IO_size_t _G_size_t
  34. #define _IO_ssize_t _G_ssize_t
  35. #define _IO_off_t _G_off_t
  36. #define _IO_pid_t _G_pid_t
  37. #define _IO_uid_t _G_uid_t
  38. #define _IO_HAVE_SYS_WAIT _G_HAVE_SYS_WAIT
  39. #define _IO_HAVE_ST_BLKSIZE _G_HAVE_ST_BLKSIZE
  40. #define _IO_BUFSIZ _G_BUFSIZ
  41. #define _IO_va_list _G_va_list
  42.  
  43. #ifdef _G_NEED_STDARG_H
  44. /* This define avoids name pollution if we're using GNU stdarg.h */
  45. #define __need___va_list
  46. #include <stdarg.h>
  47. #ifdef __GNUC_VA_LIST
  48. #undef _IO_va_list
  49. #define _IO_va_list __gnuc_va_list
  50. #endif /* __GNUC_VA_LIST */
  51. #endif
  52.  
  53. #ifndef __P
  54. #if _G_HAVE_SYS_CDEFS
  55. #include <sys/cdefs.h>
  56. #else
  57. #ifdef __STDC__
  58. #define __P(protos) protos
  59. #else
  60. #define __P(protos) ()
  61. #endif
  62. #endif
  63. #endif /*!__P*/
  64.  
  65. /* For backward compatibility */
  66. #ifndef _PARAMS
  67. #define _PARAMS(protos) __P(protos)
  68. #endif /*!_PARAMS*/
  69.  
  70. #ifndef __STDC__
  71. #define const
  72. #endif
  73. #ifndef __linux__
  74. #define _IO_USE_DTOA
  75. #endif
  76.  
  77. #define _IO_UNIFIED_JUMPTABLES 1
  78.  
  79. #if 0
  80. #ifdef _IO_NEED_STDARG_H
  81. #include <stdarg.h>
  82. #endif
  83. #endif
  84.  
  85. #ifndef EOF
  86. #define EOF (-1)
  87. #endif
  88. #ifndef NULL
  89. # if defined __GNUG__ && \
  90.     (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
  91. #  define NULL (__null)
  92. # else
  93. #  if !defined(__cplusplus)
  94. #   define NULL ((void*)0)
  95. #  else
  96. #   define NULL (0)
  97. #  endif
  98. # endif
  99. #endif
  100.  
  101. #define _IOS_INPUT    1
  102. #define _IOS_OUTPUT    2
  103. #define _IOS_ATEND    4
  104. #define _IOS_APPEND    8
  105. #define _IOS_TRUNC    16
  106. #define _IOS_NOCREATE    32
  107. #define _IOS_NOREPLACE    64
  108. #define _IOS_BIN    128
  109.  
  110. /* Magic numbers and bits for the _flags field.
  111.    The magic numbers use the high-order bits of _flags;
  112.    the remaining bits are abailable for variable flags.
  113.    Note: The magic numbers must all be negative if stdio
  114.    emulation is desired. */
  115.  
  116. #define _IO_MAGIC 0xFBAD0000 /* Magic number */
  117. #define _OLD_STDIO_MAGIC 0xFABC0000 /* Emulate old stdio. */
  118. #define _IO_MAGIC_MASK 0xFFFF0000
  119. #define _IO_USER_BUF 1 /* User owns buffer; don't delete it on close. */
  120. #define _IO_UNBUFFERED 2
  121. #define _IO_NO_READS 4 /* Reading not allowed */
  122. #define _IO_NO_WRITES 8 /* Writing not allowd */
  123. #define _IO_EOF_SEEN 0x10
  124. #define _IO_ERR_SEEN 0x20
  125. #define _IO_DELETE_DONT_CLOSE 0x40 /* Don't call close(_fileno) on cleanup. */
  126. #define _IO_LINKED 0x80 /* Set if linked (using _chain) to streambuf::_list_all.*/
  127. #define _IO_IN_BACKUP 0x100
  128. #define _IO_LINE_BUF 0x200
  129. #define _IO_TIED_PUT_GET 0x400 /* Set if put and get pointer logicly tied. */
  130. #define _IO_CURRENTLY_PUTTING 0x800
  131. #define _IO_IS_APPENDING 0x1000
  132. #define _IO_IS_FILEBUF 0x2000
  133.  
  134. /* These are "formatting flags" matching the iostream fmtflags enum values. */
  135. #define _IO_SKIPWS 01
  136. #define _IO_LEFT 02
  137. #define _IO_RIGHT 04
  138. #define _IO_INTERNAL 010
  139. #define _IO_DEC 020
  140. #define _IO_OCT 040
  141. #define _IO_HEX 0100
  142. #define _IO_SHOWBASE 0200
  143. #define _IO_SHOWPOINT 0400
  144. #define _IO_UPPERCASE 01000
  145. #define _IO_SHOWPOS 02000
  146. #define _IO_SCIENTIFIC 04000
  147. #define _IO_FIXED 010000
  148. #define _IO_UNITBUF 020000
  149. #define _IO_STDIO 040000
  150. #define _IO_DONT_CLOSE 0100000
  151.  
  152. /* The reentrent version of the libio implementation needs a semaphore for
  153.    each _IO_FILE struture.  Because we don't know how the semaphore
  154.    will be implemented we try to be very general.  */
  155. struct _IO_lock_t {
  156.   void *ptr;
  157.   short int field1;
  158.   short int field2;
  159. };
  160.  
  161. /* A streammarker remembers a position in a buffer. */
  162.  
  163. struct _IO_jump_t;  struct _IO_FILE;
  164.  
  165. struct _IO_marker {
  166.   struct _IO_marker *_next;
  167.   struct _IO_FILE *_sbuf;
  168.   /* If _pos >= 0
  169.  it points to _buf->Gbase()+_pos. FIXME comment */
  170.   /* if _pos < 0, it points to _buf->eBptr()+_pos. FIXME comment */
  171.   int _pos;
  172. #if 0
  173.     void set_streampos(streampos sp) { _spos = sp; }
  174.     void set_offset(int offset) { _pos = offset; _spos = (streampos)(-2); }
  175.   public:
  176.     streammarker(streambuf *sb);
  177.     ~streammarker();
  178.     int saving() { return  _spos == -2; }
  179.     int delta(streammarker&);
  180.     int delta();
  181. #endif
  182. };
  183.  
  184. #define _IO_file_flags _flags
  185.  
  186. struct _IO_FILE {
  187. #ifdef __SVR4_I386_ABI_L1__
  188.   /* The following pointers correspond to the C++ streambuf protocol. */
  189.   /* Note:  Tk uses the _IO_read_ptr and _IO_read_end fields directly. */
  190.   char* _IO_read_ptr;    /* Current read pointer */
  191.   char* _IO_read_end;    /* End of get area. */
  192.   char* _IO_read_base;    /* Start of putback+get area. */
  193.   int _flags;        /* High-order word is _IO_MAGIC; rest is flags. */
  194. #else
  195.   int _flags;        /* High-order word is _IO_MAGIC; rest is flags. */
  196.   /* The following pointers correspond to the C++ streambuf protocol. */
  197.   /* Note:  Tk uses the _IO_read_ptr and _IO_read_end fields directly. */
  198.   char* _IO_read_ptr;    /* Current read pointer */
  199.   char* _IO_read_end;    /* End of get area. */
  200.   char* _IO_read_base;    /* Start of putback+get area. */
  201. #endif
  202.   char* _IO_write_base;    /* Start of put area. */
  203.   char* _IO_write_ptr;    /* Current put pointer. */
  204.   char* _IO_write_end;    /* End of put area. */
  205.   char* _IO_buf_base;    /* Start of reserve area. */
  206.   char* _IO_buf_end;    /* End of reserve area. */
  207.   /* The following fields are used to support backing up and undo. */
  208.   char *_IO_save_base; /* Pointer to start of non-current get area. */
  209.   char *_IO_backup_base;  /* Pointer to first valid character of backup area */
  210.   char *_IO_save_end; /* Pointer to end of non-current get area. */
  211.  
  212.   struct _IO_marker *_markers;
  213.   
  214.   struct _IO_FILE *_chain;
  215.   
  216.   int _fileno;
  217.   int _blksize;
  218.   _IO_off_t _offset;
  219.   
  220. #define __HAVE_COLUMN /* temporary */
  221.   /* 1+column number of pbase(); 0 is unknown. */
  222.   unsigned short _cur_column;
  223.   char _unused;
  224.   char _shortbuf[1];
  225.   
  226.   /*  char* _save_gptr;  char* _save_egptr; */
  227.  
  228.   struct _IO_lock_t _IO_lock;
  229. };
  230.  
  231. #ifndef __cplusplus
  232. typedef struct _IO_FILE _IO_FILE;
  233. #endif
  234.  
  235. struct _IO_FILE_plus;
  236. extern struct _IO_FILE_plus _IO_stdin_, _IO_stdout_, _IO_stderr_;
  237. #define _IO_stdin ((_IO_FILE*)(&_IO_stdin_))
  238. #define _IO_stdout ((_IO_FILE*)(&_IO_stdout_))
  239. #define _IO_stderr ((_IO_FILE*)(&_IO_stderr_))
  240.  
  241. #ifdef __cplusplus
  242. extern "C" {
  243. #endif
  244.  
  245. extern int __underflow __P((_IO_FILE*));
  246. extern int __uflow __P((_IO_FILE*));
  247. extern int __overflow __P((_IO_FILE*, int));
  248.  
  249. #define _IO_getc(_fp) \
  250.        ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end ? __uflow(_fp) \
  251.     : *(unsigned char*)(_fp)->_IO_read_ptr++)
  252. #define _IO_peekc(_fp) \
  253.        ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end \
  254.       && __underflow(_fp) == EOF ? EOF \
  255.     : *(unsigned char*)(_fp)->_IO_read_ptr)
  256.  
  257. #define _IO_putc(_ch, _fp) \
  258.    (((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end) \
  259.     ? __overflow(_fp, (unsigned char)(_ch)) \
  260.     : (unsigned char)(*(_fp)->_IO_write_ptr++ = (_ch)))
  261.  
  262. #define _IO_feof(__fp) (((__fp)->_flags & _IO_EOF_SEEN) != 0)
  263. #define _IO_ferror(__fp) (((__fp)->_flags & _IO_ERR_SEEN) != 0)
  264.  
  265. /* This one is for Emacs. */
  266. #define _IO_PENDING_OUTPUT_COUNT(_fp)    \
  267.     ((_fp)->_IO_write_ptr - (_fp)->_IO_write_base)
  268.  
  269. extern int _IO_vfscanf __P((_IO_FILE*, const char*, _IO_va_list, int*));
  270. extern int _IO_vfprintf __P((_IO_FILE*, const char*, _IO_va_list));
  271. extern _IO_ssize_t _IO_padn __P((_IO_FILE *, int, _IO_ssize_t));
  272. extern _IO_size_t _IO_sgetn __P((_IO_FILE *, void*, _IO_size_t));
  273.  
  274. extern _IO_fpos_t _IO_seekoff __P((_IO_FILE*, _IO_off_t, int, int));
  275. extern _IO_fpos_t _IO_seekpos __P((_IO_FILE*, _IO_fpos_t, int));
  276.  
  277. extern void _IO_free_backup_area __P((_IO_FILE*));
  278.  
  279. /* They are used by libstdc++. */
  280. #define _IO_flockfile(_fp) /**/
  281. #define _IO_funlockfile(_fp) /**/
  282. #define _IO_ftrylockfile(_fp) /**/
  283. #define _IO_cleanup_region_start(_fct, _fp) /**/
  284. #define _IO_cleanup_region_end(_Doit) /**/
  285.  
  286. #ifdef __cplusplus
  287. }
  288. #endif
  289.  
  290. #endif /* _LIBIO_H */
  291.